package tt.dz.egobus.servicemanager.business.filter;

import org.apache.commons.lang3.StringUtils;
import tt.dz.egobus.servicemanager.business.distance.PointFilter;
import tt.dz.egobus.servicemanager.business.point.BusPoint;
import tt.dz.egobus.servicemanager.service.GrabRedisBusinessWorkCacheService;

/**
 * @author Anson
 * @date 17-8-29
 * @name 判断当前司机是否含有某天的预约单
 * @since 1.0.7
 */
public class BespeakDateDriverPointFilter implements PointFilter {

    private final GrabRedisBusinessWorkCacheService service;

    private final String bespeakDateStr;

    public BespeakDateDriverPointFilter(GrabRedisBusinessWorkCacheService service, String bespeakDateStr) {
        this.service = service;
        this.bespeakDateStr = bespeakDateStr;
    }

    @Override
    public boolean isFilter(BusPoint point) {
        if (point == null) {
            return false;
        }
        String driverId = point.getDriverId();
        if (StringUtils.isAnyEmpty(driverId)) {
            return false;
        }
        //若当前含有某一天的预约单,则不能满足要求
        return !service.isContainBespeakDate(driverId, bespeakDateStr);
    }
}
